package com.ajk.server.dao;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.ajk.server.dao.provider.UsersProvider;
import com.ajk.server.model.Users;
import com.ajk.server.model.query.UsersQuery;
import com.ajk.server.model.response.UserRes;
import com.ajk.shop.model.response.SimpleUserProfileRes;
/**
 * 用户表  <br>
 * t_users <br>
 * v1.0 2016-05-01
 */
 public interface UsersMapper {
 	
 	/**
 	*根据id删除 用户表
 	*/
 	@Delete("delete from t_users where id=#{id}")
 	public Integer deleteById(Integer id);
 	
 	/**
 	* 批量新增 用户表
 	*/
 	@InsertProvider(method="batchInsert",type=UsersProvider.class)
	@Options(useGeneratedKeys=true,keyColumn="id",keyProperty="list[0].id")
 	public Integer batchInsert(List<? extends Users> userss);
 	
 	/**
 	* 新增 用户表
 	*/
 	@InsertProvider(method="insert",type=UsersProvider.class)
	@Options(useGeneratedKeys=true)
 	public Integer insert(Users domain);
 
 	
 	/**
 	*更新 用户表
 	*/
 	@UpdateProvider(method="update",type=UsersProvider.class)
 	public Integer update(Users domain);
 	
 	/**
 	*根据ID查询 用户表
 	*/
	@Select("select * from t_users where id=#{id}")
	public UserRes findById(Integer id);
	
	/**
 	*根据ID查询 用户表
 	*/
	@Select("select * from t_users where mobile=#{mobile}")
	public UserRes findByMobile(String mobile);
	
	@Select("select * from t_users where id=#{id}")
	@Options(flushCache=true)
	public Users findByIdWithOutCache(Integer id);
	
	
 	
 	/**
 	*通过query 查询 用户表
 	*/
 	@SelectProvider(method="findByQuery",type=UsersProvider.class)
 	public List<Users> findByQuery(UsersQuery query);
 	
 	/**
 	*通过query count总条数
 	*/
 	@SelectProvider(method="countByQuery",type=UsersProvider.class)
 	public Integer countByQuery(UsersQuery query);
 	
 	/**
 	* 通过ids查询
 	*/
 	@SelectProvider(method="findSimpleByIds",type=UsersProvider.class)
 	public List<SimpleUserProfileRes> findSimpleByIds(List<Integer> ids);
 	
 	@Select("select avatar,name,id user_id from t_users where id = #{id}")
 	public SimpleUserProfileRes findSimpleById(Integer id);
 	
	/**
 	* 通过ids查询
 	*/
 	@SelectProvider(method="findByIds",type=UsersProvider.class)
 	public List<Users> findByIds(List<Integer> ids);
 	

}	